package cn.anzhiyublog.staranimegallery.mapper;

import cn.anzhiyublog.staranimegallery.model.domain.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 用户mapper
 *
 * @author 安知一只鱼
 */
public interface UserMapper extends BaseMapper<User> {
    /**
     * 查询用户密码
     */
    @Select("SELECT password FROM user WHERE id = #{id} LIMIT 1")
    String selectPasswordById(long id);

    /**
     * 设置头像
     */
    @Update("UPDATE `user` JOIN `picture` ON `picture`.`id` = #{pictureId} SET `user`.`avatar` = `picture`.`thumbnail_url` WHERE `user`.`id` = #{userId}")
    boolean setAvatar(long userId, long pictureId);
}
